package com.isunland.managesystem.base;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.NavUtils;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.RadioGroup;
import com.isunland.managesystem.R;
import com.isunland.managesystem.entity.CurrentUser;

public abstract class BaseRecoverTaskFragment extends Fragment {

  protected BaseVolleyActivity mActivity;
  protected CurrentUser mCurrentUser;

  protected RadioGroup mrgAlertMessage;//提醒方式
  protected CheckBox mcbAlertStation;//站内消息
  protected CheckBox mcbAlertPhone;//手机消息
  protected EditText metChangeCause;//转交原因
  protected String recipientName = "";//接收人姓名
  protected String recipientId = "";//接收人id
  protected String type1 = "3";//消息提醒方式:站内
  protected String type2 = "";//消息提醒方式:手机
  protected String runId = "";

  @Override public void onCreate(Bundle savedInstanceState) {
    setHasOptionsMenu(true);//显示菜单按钮
    if (NavUtils.getParentActivityName(getActivity()) != null) {
      ((BaseVolleyActivity) getActivity()).getSupportActionBar()
          .setDisplayHomeAsUpEnabled(true);//回退键
    }

    mActivity = (BaseVolleyActivity) getActivity();
    mCurrentUser = CurrentUser.newInstance(getActivity());
    setTitle();
    super.onCreate(savedInstanceState);
  }

  /**
   * 设置标题
   */
  protected abstract void setTitle();

  @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.menu_confirm, menu);
    super.onCreateOptionsMenu(menu, inflater);
  }

  @Override public View onCreateView(LayoutInflater inflater, ViewGroup container,
      Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_recover_task, container, false);
    mrgAlertMessage = (RadioGroup) v.findViewById(R.id.rg_alert_message);//接收人
    mcbAlertStation = (CheckBox) v.findViewById(R.id.cb_alert_station);//站内消息
    mcbAlertPhone = (CheckBox) v.findViewById(R.id.cb_alert_phone);//手机消息
    metChangeCause = (EditText) v.findViewById(R.id.et_change_cause);//转交原因

    //		//站内消息
    //		mcbAlertStation.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
    //
    //			@Override
    //			public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    //				//如果被选中
    //				if (isChecked) {
    //					type1="3";
    //				}else {
    //					type1="";
    //				}
    //
    //			}
    //		});
    //		//手机消息
    //		mcbAlertPhone.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
    //
    //			@Override
    //			public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    //				//如果被选中
    //				if (isChecked) {
    //					type2="2";
    //				}else {
    //					type2="";
    //				}
    //
    //			}
    //		});
    initData();
    return v;
  }

  /**
   * 初始化数据
   */
  protected void initData() {

  }
}
